This invention relates to methods and apparatus for use in digital computers and digital data processors for converting data from one format to another.
Peripheral input/output devices supply data to digital data processors in the form of binary coded characters wherein each character represents a single alphabetical letter or numerical digit or graphic symbol (for example, punctuation mark) or control character. In a typical class of present-day, large-scale data processors, each character has a length of one byte, with a byte being defined as a sequence of eight adjacent binary data bits. Eight bits provide 256 different unique code values and, hence, a character set that can represent up to 256 different characters.
In the case of numerical data, the data from the input/output device is in a zoned decimal format wherein the lower order four bits of each character or byte constitute a digit field and the higher order four bits of each character or byte constitute a zone field. The four-bit digit field contains a binary coded decimal representation of a decimal digit value and the 4-bit zone field contains a unique zone code which identifies the character as being a numerical value and not an alphabetical letter, graphic symbol or control character.
Unfortunately, the arithmetic and logic units which perform the numerical calculations in most present-day data processors cannot handle numerical data in the zoned format. The presence of the zone fields would produce erroneous results. Thus, it is necessary to convert the zoned numerical data received from an input/output device to a packed decimal format before using it to perform numerical calculations. This is accomplished by deleting the zone fields and placing the digit fields adjacent to each other so as to form continuous sequences having only digit fields. The performance of this zoned-to-packed format conversion is commonly referred to as "packing".
In typical data processors, the programmer has the option of directing the machine to perform the numerical calculations using either decimal arithmetic or pure binary arithmetic. In the latter case, it is further necessary to convert the packed decimal numerical data to a pure binary format before performing the calculations. In either case, however, the original zoned data must be converted to the packed format.
A converse type of situation applies when it is desired to send the results of numerical calculations back to a peripheral input/output device. The numerical results must be converted from the packed format back to the zoned format before the data is returned to the input/output device. This requires the separation of the digit fields and the insertion of the unique zone field code for numerical characters in the intervening spaces. The performance of this packed-to-zoned format conversion is commonly referred to as "unpacking". For the case of pure binary calculations, the binary results are first converted to the packed format and the packed format results are then converted to the zoned format.
As can be appreciated from the foregoing, when a digital computer or data processor is used to perform user application programs involving numerical data and numerical calculations, a goodly number of packing and unpacking operations can be required. Unfortunately, with present-day data processors, these packing and unpacking operations are relatively time consuming. With present-day processors, the bytes of data are packed or unpacked one byte at a time, with at least two machine cycles being required to obtain one packed byte or, conversely, to unpack one packed byte. Thus, it would be very desirable to have a faster way of doing the data packing and unpacking. This would provide a significant improvement in the performance of the data processor. At the same time, it would be even more desirable if this could be accomplished with a minimum of cost, such as by adding a relatively small amount of additional circuitry to the circuitry otherwise required by the data processor.